from google.appengine.ext import db

class User(db.Model):
  name = db.StringProperty(required=True)
  user = db.UserProperty(required=True)
  projects = db.ListProperty(db.Key)
  
  def join_project(self, p):
    self.projects.append(p.key())
    self.put()

class Project(db.Model):
  name = db.StringProperty(required=True)
  manager = db.Reference(User, required=True)

  def get_members(self):
    q = User.all().filter("projects =", self.key())
    users = q.fetch(100)
    return users

